package com.adjy.pathbuilders.screens;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;

import com.adjy.pathbuilders.R;
import com.adjy.pathbuilders.commons.FontLoader;
import com.adjy.pathbuilders.objects.button.TextImageButton;
import com.adjy.pathbuilders.objects.button.listeners.BackToMainMenuButtonListener;
import com.adjy.pathbuilders.rendering.GameCanvas;
import com.adjy.pathbuilders.rendering.loading.AnimationFactory;
import com.adjy.pathbuilders.rendering.loading.WeakReferenceBitmap;
import com.adjy.pathbuilders.state.Game;

public class About implements GameScreen {
	
	private Bitmap aboutInfoBackground;
	private Bitmap logo;
	private Paint aboutPaint;
	private TextImageButton exitButton;
	private AnimationFactory factory;
	private Game game;
	
	public About(AnimationFactory factory, Game game) {
		this.factory = factory;
		this.game = game;
	}
	
	public void input(MotionEvent event) {
		exitButton.input(event);
	}

	@Override
	public void load() {
		aboutInfoBackground = factory.getImage("main_menu_bg");
		logo = factory.getImage("logo");
		
		aboutPaint = new Paint();
		aboutPaint.setColor(Color.BLACK);
		aboutPaint.setTextSize(FontLoader.getInstance().getFontSize() / 3);
		aboutPaint.setAntiAlias(true);
		aboutPaint.setFakeBoldText(true);
		
		exitButton = new TextImageButton(
				200, 380,
				new BackToMainMenuButtonListener(game),
				new WeakReferenceBitmap(factory, "menu_button_selected"),
				new WeakReferenceBitmap(factory, "menu_button_unselected"),
				game.getContext().getString(R.string.back));
	}

	@Override
	public void release() {
		factory.releaseImages("main_menu_bg", "logo", "menu_button_selected", "menu_button_unselected");
	}

	@Override
	public void render(GameCanvas mcanvas, float timeElapsed) {
		mcanvas.drawBackground(aboutInfoBackground);
		mcanvas.drawBitmapWithConversion(logo, 185, 20);
		
		mcanvas.drawTextWithConversion(game.getContext().getString(R.string.university),
				250,
				210, aboutPaint);
		
		mcanvas.drawTextWithConversion(game.getContext().getString(R.string.developed_by), 250, 250, aboutPaint);
		mcanvas.drawTextWithConversion("Armstrong Mardilson da Silva Goes", 280, 280, aboutPaint);
		mcanvas.drawTextWithConversion("Diego Pedro", 280, 300, aboutPaint);
		mcanvas.drawTextWithConversion("Joeffison Silverio de Andrade", 280, 320, aboutPaint);
		mcanvas.drawTextWithConversion("Yuri Farias Gomes", 280, 340, aboutPaint);

		exitButton.render(mcanvas, timeElapsed);
	}

	@Override
	public void step(float timePassed) {
		// TODO Auto-generated method stub
		
	}
}
